package test;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import org.apache.log4j.Logger;

public class Hello implements Runnable {
	private static Logger log = Logger.getLogger(Hello.class);

	public static void main(String[] args) {
		log.info("start");
		new Hello("").run();
	}

	public Hello() {
		this("default");
	}

	public Hello(String name) {
	}

	public void run() {
		try {
			OutputStream out = new FileOutputStream("/dev/null");
			final BufferedOutputStream bos = new BufferedOutputStream(out);
			for (int i = 0; i < 10; i++) {
				int remain = i % 3;
				int value = 0;
				switch (remain) {
				case 0:
					value = 1;
					break;
				case 1:
					value = 1 << 1;
					break;
				case 2:
					value = 1 << 2;
					break;
				default:
					throw new RuntimeException();
				}
				bos.write((byte) value);
			}
			new Object() {
				@Override
				protected void finalize() throws Throwable {
					super.finalize();
					bos.flush();
					bos.close();
				}

			};
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			log.error("ioe", e);
		}
	}
}
